package com.playball.lottery.frm.buyhall;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.playball.lottery.R;
import com.playball.lottery.ApplicationData;
import com.playball.lottery.JddMainActivity;
import com.playball.lottery.base.BaseActivity;
import com.playball.lottery.customview.BaseGroupAdapter;
import com.playball.lottery.customview.ChildDTO;
import com.playball.lottery.customview.GroupDTO;
import com.playball.lottery.customview.ShowTipDialog;
import com.playball.lottery.frm.help.CaiPiaoHelp;
import com.playball.lottery.frm.kjinfo.KjinfoMatchResult;
import com.playball.lottery.frm.yhzx.BetRecordActivity;
import com.playball.lottery.frm.yhzx.LoginActivity;
import com.playball.lottery.nt.GetRequestParams;
import com.playball.lottery.util.ConvertJsonToList;
import com.playball.lottery.util.DateUtil;
import com.playball.lottery.util.DefConstants;
import com.playball.lottery.util.JCZQUtil;
import com.playball.lottery.util.LotConstants;


/**
 * 竞彩足球玩法购彩操作界面
 * 
 * @author Administrator
 * 
 */
public class JcfootballActivity extends BaseActivity implements Serializable, DefConstants {
	/** 上下文内容 */
	private Context context = null;
	private static final long serialVersionUID = 1L;

	private List<GroupDTO> groups;
	private List<ChildDTO> str_childs;

	/**
	 * 竞彩足球的展开列表的适配器
	 */
	private static BaseGroupAdapter jclist_adapter = null;
	/**
	 * 竞彩足球混合投注适配器
	 */
	private static FootBallHHTZAdapter jczq_hhtz_adapter = null;

	/**
	 * 竞彩足球的展开列表
	 */
	private ExpandableListView jclist;
	private static List<Map<String, Object>> issueData;
	/** 期号 */
	public String issueName; // 期号
	public String issueID;//期次
	public String wkName;// 周几
	public String mCount;// 几场

	public String mId;// 赛事编号
	public String nMm;// 赛事类型
	public String eTime;// 截至时间
	public String hTeam;// 主队
	public String eQ;// 让球
	public String vTeam;// 让球
	/** 让球胜平负SP值 */
	public String sPRqspf;
	/** 胜平负SP值 */
	public String sPspf;
	/** 半全场SP值 */
	public String sPBQC;
	/** 总进球SP值 */
	public String sPZJQ;//
	/** 比分主胜SP值 */
	public String sPBFS;// 比分主胜SP值
	/** 比分平SP值 */
	public String sPBFP;// 比分平SP值
	/** 比分主负SP值 */
	public String sPBFF;// 比分主负SP值

	public boolean str_sbtn;// 零时胜
	public boolean str_fbtn;// 零时负
	public boolean str_pbtn;// 零时平

	private PopupWindow m_popupWindow;

	public ShowTipDialog showDialog = new ShowTipDialog();

	TextView buy_jcxh_Button02;

	TextView tv_selectNum;

	TextView bottom_tv_tips;

	Button buy_jcxh_Button01;

	private TextView yzjs_tip;

	/** 竞彩足球玩法 */
	//modify by rainy remove YZJS
//	private String strZQWF = "YZJS";
//	private String strLot = "一场决胜";
	private String strLot = "让球胜平负";
	private String strZQWF = "RQSPF";
	public long randonTimeStamp;
	/** 菜单弹出框 */
	private PopupWindow menu_popupWindow;
	/** 菜单弹出框 */
	private View menutypeview;
	private TextView top_title_tvplaytype;

	/** 判断是否从推送通知过来 */
	private Boolean ifPush;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.context = this;
		randonTimeStamp = System.currentTimeMillis();
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.jdd_jczq);

		AsyncLoader task = new AsyncLoader();
		String[] parms = new String[2];
		parms[0] = "202";
		JSONObject jsob = new JSONObject();
		parms[1] = jsob.toString();
		task.execute(parms);
		ifPush = getIntent().getBooleanExtra("ifPush", false);
		// 初始化表单
		initView();
		tv_selectNum = (TextView) findViewById(R.id.bottom_tv_select_match);

		// 清空
		buy_jcxh_Button01.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (TextUtils.equals(strZQWF, "ZQHH") || TextUtils.equals(strZQWF, "SPFRQNEW")) {
					if (jczq_hhtz_adapter.getSelNum() >= 1) {
						clearData();
						jczq_hhtz_adapter.clearSel();
						/*
						 * MyDialog.Builder dialog = new MyDialog.Builder(
						 * JcfootballActivity.this); dialog.setTitle("清空场次提示");
						 * dialog.setMessage("清空后您已选择的场次列表将会清空，确认继续?");
						 * dialog.setPositiveButton("确定", new
						 * DialogInterface.OnClickListener() {
						 * 
						 * @Override public void onClick(DialogInterface dialog,
						 * int which) { clearData();
						 * jczq_hhtz_adapter.clearSel(); dialog.cancel(); } });
						 * dialog.setNegativeButton("取消", new
						 * DialogInterface.OnClickListener() {
						 * 
						 * @Override public void onClick(DialogInterface dialog,
						 * int which) { dialog.cancel(); } }).create().show();
						 */
					} else {
						Toast.makeText(JcfootballActivity.this, R.string.no_selection_session, Toast.LENGTH_SHORT)
								.show();
					}
				} else {
					if (ApplicationData.getInstance().getList_jcdto().size() >= 1) {
						clearData();

						/*
						 * MyDialog.Builder dialog = new MyDialog.Builder(
						 * JcfootballActivity.this); dialog.setTitle("清空号码提示");
						 * dialog.setMessage("清空后您已选择的号码列表将会清空，确认继续?");
						 * dialog.setPositiveButton("确定", new
						 * DialogInterface.OnClickListener() {
						 * 
						 * @Override public void onClick(DialogInterface dialog,
						 * int which) { clearData(); dialog.cancel(); } });
						 * dialog.setNegativeButton("取消", new
						 * DialogInterface.OnClickListener() {
						 * 
						 * @Override public void onClick(DialogInterface dialog,
						 * int which) { dialog.cancel(); } }).create().show();
						 */
					} else {
						Toast.makeText(JcfootballActivity.this, R.string.no_selection_session, Toast.LENGTH_SHORT)
								.show();
					}
				}
			}
		});

		// 提交按钮
		buy_jcxh_Button02.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				jczqSubmit();
			}
		});
	}

	public void jczqSubmit(){
		
		if (checkUserLogin()) {
			if (strZQWF.equals("YZJS")) {
				if (ApplicationData.getInstance().getList_jcdto().size() > 0) {
					if (ApplicationData.getInstance().getList_jcdto().size() < 2) {
						Intent intent = new Intent();
						intent.putExtra("list_jcdto", ApplicationData.getInstance().getList_jcdto());
						intent.putExtra("IssueName", issueName);
						intent.putExtra("issueID", issueID);
						intent.putExtra("strZQWF", strZQWF);
						intent.setClass(JcfootballActivity.this, YZJSxhlbActivity.class);
						JcfootballActivity.this.startActivityForResult(intent, REQ_CODE_JCFOOT);// (intent);
					} else {
						Toast.makeText(JcfootballActivity.this, R.string.option_one_most, Toast.LENGTH_SHORT)
								.show();
					}
				} else {
					Toast.makeText(JcfootballActivity.this, R.string.select_at_least_one, Toast.LENGTH_SHORT)
							.show();
				}
			} else if (TextUtils.equals(strZQWF, "ZQHH") || TextUtils.equals(strZQWF, "SPFRQNEW")) {

				List<ChildDTO> caculateData = new ArrayList<ChildDTO>();
				for (GroupDTO groupDTO : jczq_hhtz_adapter.getDatas()) {
					for (ChildDTO childDTO : groupDTO.children) {

						if (TextUtils.equals(strZQWF, "SPFRQNEW")) {
							String sp = "";
							if (childDTO.str_sbtn) {
								sp += ("spf," + childDTO.getsPspf().split("\\|")[0] + "/");
							}
							if (childDTO.str_pbtn) {
								sp += ("spf," + childDTO.getsPspf().split("\\|")[1] + "/");
							}
							if (childDTO.str_fbtn) {
								sp += ("spf," + childDTO.getsPspf().split("\\|")[2] + "/");
							}
							if (childDTO.str_rqsbtn) {
								sp += ("rq," + childDTO.getsPRqspf().split("\\|")[0] + "/");
							}
							if (childDTO.str_rqpbtn) {
								sp += ("rq," + childDTO.getsPRqspf().split("\\|")[1] + "/");
							}
							if (childDTO.str_rqfbtn) {
								sp += ("rq," + childDTO.getsPRqspf().split("\\|")[2] + "/");
							}
							childDTO.zqhhtzsp = sp;
						}

						if (!TextUtils.isEmpty(childDTO.hhtzzq1) || !TextUtils.isEmpty(childDTO.hhtzzq2)
								|| !TextUtils.isEmpty(childDTO.hhtzzq3) || !TextUtils.isEmpty(childDTO.hhtzzq4)
								|| !TextUtils.isEmpty(childDTO.hhtzzq5)) {
							caculateData.add(childDTO);
						}
					}
				}
				int size = caculateData.size();
				if (size > 1) {
					if (size < 16) {
						Intent intent = new Intent();
						intent.putExtra("Activity", "JcfootballActivity");
						intent.putExtra("datas", jczq_hhtz_adapter.getDatas());
						intent.putExtra("IssueName", issueName);
						intent.putExtra("issueID", issueID);
						intent.putExtra("strZQWF", strZQWF);
						intent.setClass(JcfootballActivity.this, JczqHhtzDetail.class);
						JcfootballActivity.this.startActivityForResult(intent, REQ_CODE_JCFOOT);
					} else {
						Toast.makeText(JcfootballActivity.this, R.string.select_fifteen_games_at_most,
								Toast.LENGTH_SHORT).show();
					}
				} else {
					Toast.makeText(JcfootballActivity.this, R.string.select_at_least_two, Toast.LENGTH_SHORT)
							.show();
				}

			} else if (!strZQWF.equals("BF")&&!strZQWF.equals("ZJQ")&&!strZQWF.equals("BQC")) {
				if ((ApplicationData.getInstance().getList_jcdto().size()==1
						&& ApplicationData.getInstance().getList_jcdto().get(0).isSingle() ==1)
						||ApplicationData.getInstance().getList_jcdto().size() > 1) {
					if (ApplicationData.getInstance().getList_jcdto().size() < 16) {
						Intent intent = new Intent();
						intent.putExtra("Activity", "JcfootballActivity");
						intent.putExtra("list_jcdto", ApplicationData.getInstance().getList_jcdto());
						intent.putExtra("IssueName", issueName);
						intent.putExtra("issueID", issueID);
						intent.putExtra("strZQWF", strZQWF);
						intent.setClass(JcfootballActivity.this, JcfootxhlbActivity.class);
						JcfootballActivity.this.startActivityForResult(intent, REQ_CODE_JCFOOT);// (intent);
					} else {
						Toast.makeText(JcfootballActivity.this, R.string.select_fifteen_games_at_most,
								Toast.LENGTH_SHORT).show();
					}
				} else {
					Toast.makeText(JcfootballActivity.this, R.string.select_at_least_two, Toast.LENGTH_SHORT)
							.show();
				}
			} else {// 比分有单关，1 场
				if (ApplicationData.getInstance().getList_jcdto().size() > 0) {
					if (ApplicationData.getInstance().getList_jcdto().size() < 16) {
						Intent intent = new Intent();
						intent.putExtra("Activity", "JcfootballActivity");
						intent.putExtra("list_jcdto", ApplicationData.getInstance().getList_jcdto());
						intent.putExtra("IssueName", issueName);
						intent.putExtra("issueID", issueID);
						intent.putExtra("strZQWF", strZQWF);
						intent.setClass(JcfootballActivity.this, JcfootxhlbActivity.class);
						JcfootballActivity.this.startActivityForResult(intent, REQ_CODE_JCFOOT);// (intent);
					} else {
						Toast.makeText(JcfootballActivity.this, R.string.select_fifteen_games_at_most,
								Toast.LENGTH_SHORT).show();
					}
				} else {
					Toast.makeText(JcfootballActivity.this, R.string.select_at_least_one, Toast.LENGTH_SHORT)
							.show();
				}
			}
		} else {
			Intent intent = new Intent();
			intent.setClass(JcfootballActivity.this, LoginActivity.class);
			startActivityForResult(intent, REQ_CODE_JCFOOT_LOGIN);
		}
	}
	
	public void onResume() {
		super.onResume();
		 // 统计时长
	}

	public void onPause() {
		super.onPause();
		
	}

	public static void clearHhtzSel() {
		if (jczq_hhtz_adapter != null)
			jczq_hhtz_adapter.clearSel();
	}

	class AsyncLoader extends AsyncTask<String, Integer, String> {// 继承AsyncTask

		protected void onPreExecute() {
			showDialog.showDialog(JcfootballActivity.this);
		}
		@Override
		protected String doInBackground(String... params) {
			// 处理后台执行的任务，在后台线程执行
			String strResult;
			String action = params[0];
			strResult = GetRequestParams.getRequestResultKjInfo(params[1], action, getApplicationContext());
			return strResult;
		}
		protected void onProgressUpdate(Integer... progress) {
		}
		protected void onPostExecute(String result) {
			// 本地数据
			// result=JczqData.createJCZQJSON();
			if (result != null) {
				// 获取接口数据
				try {
					JSONTokener jsonParser = new JSONTokener(result);
					JSONObject js = (JSONObject) jsonParser.nextValue();
					if (Integer.parseInt(js.getString("Code")) == 0) {
						if (!"".equals(js.getString("Data"))) {
							issueData = getCurrentlData(result);
							// 获取比赛场次信息赋值给groups
							getMatchInfo();
							// 构建ExpandableListView的适配器
							jclist_adapter = new BaseGroupAdapter(JcfootballActivity.this, groups, strZQWF);
							jclist.setAdapter(jclist_adapter); // 绑定视图－适配器
							jclist.expandGroup(0);
						}
					} else {
						Toast.makeText(JcfootballActivity.this, js.getString("Data"), Toast.LENGTH_SHORT).show();
					}
					showDialog.closeDialog();
				} catch (JSONException ex) {
					// 异常处理代码
					Log.e("error", ex.toString());
				} finally {
					showDialog.closeDialog();
				}
			} else {
				Toast.makeText(JcfootballActivity.this, getString(R.string.problem_01), Toast.LENGTH_LONG).show();
			}
		}

		// 5.完成后操作
		protected void onCancelled() {
		}
	}

	// 获取比赛场次信息
	public void getMatchInfo() {
		groups = new ArrayList<GroupDTO>();
		if (issueData != null) {
			// //删除服务器无效数据
			for (int i = 0; i < issueData.size(); i++) {
				mCount = issueData.get(i).get("MCount").toString();
				issueName = issueData.get(i).get("issue").toString();// 期号
				issueID = issueData.get(i).get("ID").toString();
				wkName = issueData.get(i).get("Wk").toString();// 周几
				tv_selectNum.setText(Html.fromHtml("已选 " + "<font color=#fe5052>" + 0 + "</font>" + " 场"));

				List<Map<String, Object>> matchData = ConvertJsonToList.getList(issueData.get(i).get("Matches")
						.toString());
				// 根据对应彩种处理数据//如果没有SP值，则不显示,删除此行数据//对比网站
				if (strZQWF.equals("SPF") || strZQWF.equals("YZJS")) {
					for (int j = 0; j < matchData.size(); j++) {
						if ("".equals(matchData.get(j).get("SpSPF").toString())) {
							matchData.remove(j);
							j--;// 这里防止有遗漏Item,正确做法让指针向前移动
						}
					}
				} else if (strZQWF.equals("BQC")) {
					// 如果没有SP值，则不显示,删除此行数据
					for (int j = 0; j < matchData.size(); j++) {
						if ("||||||||".equals(matchData.get(j).get("SpBQC").toString())) {
							matchData.remove(j);
							j--;// 这里防止有遗漏Item,正确做法让指针向前移动
						}
					}
				} else if (strZQWF.equals("ZJQ")) {
					for (int j = 0; j < matchData.size(); j++) {
						if ("|||||||".equals(matchData.get(j).get("SpZJQ").toString())) {
							matchData.remove(j);
							j--;// 这里防止有遗漏Item,正确做法让指针向前移动
						}
					}
				} else if (strZQWF.equals("BF")) {
					for (int j = 0; j < matchData.size(); j++) {
						if ("||||||||||||||||||||||||||||||".equals(matchData.get(j).get("SpCBF").toString())) {
							matchData.remove(j);
							j--;// 这里防止有遗漏Item,正确做法让指针向前移动
						}
					}
				}
				// 重新对可投注比赛场数计算
				mCount = matchData.size() + "";
				// Log.v("bas", "删除执行hou获取数据matchData="+matchData.toString());

				List<ChildDTO> childs = new ArrayList<ChildDTO>();
				str_childs = new ArrayList<ChildDTO>();
				for (int j = 0; j < matchData.size(); j++) {

					mId = matchData.get(j).get("MID").toString();
					nMm = matchData.get(j).get("NMm").toString();// 赛事类型
					eTime = matchData.get(j).get("ETime").toString();// 截至时间
					hTeam = matchData.get(j).get("HTeam").toString();// 主队
					eQ = matchData.get(j).get("Rq").toString();// 让球
					vTeam = matchData.get(j).get("VTeam").toString();// 让球
					sPRqspf = matchData.get(j).get("SpRQSPF").toString();// 让球胜平负SP值
					sPspf = matchData.get(j).get("SpSPF").toString();// 胜平负SP值
					sPBQC = matchData.get(j).get("SpBQC").toString();// 半全场SP值
					sPZJQ = matchData.get(j).get("SpZJQ").toString();// 总进球SP值
					int isSingle = Integer.parseInt(matchData.get(j).get("IsSingle").toString());
					// 网络数据
					String spBF = JCZQUtil.changeCBF3(matchData.get(j).get("SpCBF").toString());
					if (spBF.split(",").length >= 2) {
						sPBFS = spBF.split(",")[0];
						sPBFP = spBF.split(",")[1];
						sPBFF = spBF.split(",")[2];
					}

					ChildDTO child = new ChildDTO();
					child.setWeek(wkName);
					child.setmId(mId);
					child.setnMm(nMm);
					child.seteTime(eTime);
					child.sethTeam(hTeam);
					child.seteQ(eQ);
					child.setvTeam(vTeam);
					child.setSingle(isSingle);

					if ((strZQWF.equals("RQSPF")) || (strZQWF.equals("SPF")) || (strZQWF.equals("YZJS"))) {
						if (strZQWF.equals("RQSPF")) {
							child.setsPRqspf(sPRqspf.replace("|", "-"));
						} else if (strZQWF.equals("SPF")) {
							child.setsPspf(sPspf.replace("|", "-"));
						} else {
							child.setsPRqspf(sPRqspf.replace("|", "-"));
							child.setsPspf(sPspf.replace("|", "-"));
						}
						child.setStr_sbtn(false);
						child.setStr_fbtn(false);
						child.setStr_pbtn(false);
					} else if (strZQWF.equals("BQC")) {
						// 半全场赛果gridview是否显示
						child.setShowBQCGrid(false);
						child.setsPbqc(sPBQC);
						child.setStr_sbtn(false);
						// 半全场赛果gridview按钮状态初始化
						List<String> list_gridview_selectstate = new ArrayList<String>();
						for (int k = 0; k < 9; k++) {// 半全场9中赛果
							list_gridview_selectstate.add("false");
						}
						child.setList_bqcgridview_selectstate(list_gridview_selectstate);
						// 半全场赛果gridview按钮SP list初始化
						List<String> list_gridview_selectsp = new ArrayList<String>();
						for (int k = 0; k < 9; k++) {// 半全场9中赛果sp
							list_gridview_selectsp.add("0");
						}
						child.setList_bqcgridview_selectsp(list_gridview_selectsp);
						child.setBtnBQCcontent("点击弹出下拉列表");
					} else if (strZQWF.equals("ZJQ")) {
						child.setsPzjq(sPZJQ);
						// 总进球gridview按钮状态初始化
						List<String> list_gridview_selectstate = new ArrayList<String>();
						for (int k = 0; k < 8; k++) {// 总进球8种赛果
							list_gridview_selectstate.add("false");
						}
						child.setList_zjqgridview_selectstate(list_gridview_selectstate);
						// 总进球gridview按钮sp list初始化
						List<String> list_gridview_selectsp = new ArrayList<String>();
						for (int k = 0; k < 8; k++) {// 总进球8种赛果sp
							list_gridview_selectsp.add("0");
						}
						child.setList_zjqgridview_selectsp(list_gridview_selectsp);
					} else if (strZQWF.equals("BF")) {
						// 比分主胜gridview是否显示
						child.setShowBFS(false);
						child.setShowBFP(false);
						child.setShowBFF(false);
						// 存储比分SP值
						child.setsPbfs(sPBFS);
						child.setsPbfp(sPBFP);
						child.setsPbff(sPBFF);
						// 设置按钮选择状态为未选择
						child.setStr_sbtn(false);
						child.setStr_fbtn(false);
						child.setStr_pbtn(false);
						// 比分主胜gridview按钮状态初始化
						List<String> list_bfsgridview_selectstate = new ArrayList<String>();
						for (int k = 0; k < 13; k++) {// 比分主胜13种赛果
							list_bfsgridview_selectstate.add("false");
						}
						// Log.i("zjq",
						// "list_gridview_selectstate= "+list_gridview_selectstate.toString());
						child.setList_bfsgridview_selectstate(list_bfsgridview_selectstate);
						// 比分平gridview按钮状态初始化
						List<String> list_bfpgridview_selectstate = new ArrayList<String>();
						for (int k = 0; k < 5; k++) {// 比分平5种赛果
							list_bfpgridview_selectstate.add("false");
						}
						child.setList_bfpgridview_selectstate(list_bfpgridview_selectstate);
						// 比分主负gridview按钮状态初始化
						List<String> list_bffgridview_selectstate = new ArrayList<String>();
						for (int k = 0; k < 13; k++) {// 比分主负13种赛果
							list_bffgridview_selectstate.add("false");
						}
						child.setList_bffgridview_selectstate(list_bffgridview_selectstate);
						// 设置按钮初始文字内容
						child.setBtnbfscontent("主胜");
						child.setBtnbfpcontent("平");
						child.setBtnbffcontent("主负");
						// 比分sp值选择list初始化
						List<String> list_bfsgridview_selectsp = new ArrayList<String>();
						for (int k = 0; k < 13; k++) {// 比分主胜13种赛果SP
							list_bfsgridview_selectsp.add("0");
						}
						child.setList_bfsgridview_selectsp(list_bfsgridview_selectsp);

						List<String> list_bfpgridview_selectsp = new ArrayList<String>();
						for (int k = 0; k < 5; k++) {// 比分平5种赛果SP
							list_bfpgridview_selectsp.add("0");
						}
						child.setList_bfpgridview_selectsp(list_bfpgridview_selectsp);

						List<String> list_bffgridview_selectsp = new ArrayList<String>();
						for (int k = 0; k < 13; k++) {// 比分主负13种赛果SP
							list_bffgridview_selectsp.add("0");
						}
						child.setList_bffgridview_selectsp(list_bffgridview_selectsp);
					} else if (strZQWF.equals("ZQHH") || strZQWF.equals("SPFRQNEW")) {
						if (matchData.get(j).get("SpSPF") != null)
							child.setsPspf(matchData.get(j).get("SpSPF").toString());
						if (matchData.get(j).get("SpRQSPF") != null)
							child.setsPRqspf(matchData.get(j).get("SpRQSPF").toString());
						if (matchData.get(j).get("SpBQC") != null)
							child.setsPbqc(matchData.get(j).get("SpBQC").toString());
						if (matchData.get(j).get("SpZJQ") != null)
							child.setsPzjq(matchData.get(j).get("SpZJQ").toString());
						if (matchData.get(j).get("SpCBF") != null)
							child.setsPbf(matchData.get(j).get("SpCBF").toString());
					}
					childs.add(child);
					str_childs.add(child);
				}
				String temp = null;
				if (issueName.length() >= 8) {
					temp = issueName.substring(0, 4) + "-" + issueName.substring(4, 6) + "-"
							+ issueName.substring(6, issueName.length());
				} else {
					temp = issueName;
				}
				if (wkName != null) {
					GroupDTO group = new GroupDTO(issueName, wkName + "  " + temp + "  共" + mCount + "场比赛可投注", childs);
					groups.add(group);
				}
			}
		}
	}

	public String getWkByData(String data) {
		Calendar calendar = Calendar.getInstance();
		int year = Integer.parseInt(data.substring(0, 4));
		int month = Integer.parseInt(data.substring(4, 6));
		int day = Integer.parseInt(data.substring(6));
		calendar.set(year, month - 1, day);// 设置当前时间,月份是从0月开始计算
		int number = calendar.get(Calendar.DAY_OF_WEEK);// 星期表示1-7，是从星期日开始，
		String[] str = { "", "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", };
		// System.out.println(str[number]);
		String myWeek = "1";
		switch (number) {
		case 1:
			myWeek = "7";
			break;
		case 2:
			myWeek = "1";
			break;
		case 3:
			myWeek = "2";
			break;
		case 4:
			myWeek = "3";
			break;
		case 5:
			myWeek = "4";
			break;
		case 6:
			myWeek = "5";
			break;
		case 7:
			myWeek = "6";
			break;
		default:
			break;
		}
		return myWeek;

	}

	// 初始化
	public void initView() {
		jclist = (ExpandableListView) findViewById(R.id.prelv_matches);

		buy_jcxh_Button01 = (Button) findViewById(R.id.buy_ssqxh_Buttondel);
		buy_jcxh_Button02 = (TextView) findViewById(R.id.bottom_right_btn);
		yzjs_tip = (TextView) findViewById(R.id.yzjs_tip);
		bottom_tv_tips = (TextView) findViewById(R.id.bottom_tv_tips);
		bottom_tv_tips.setVisibility(View.GONE);
//		bottom_tv_tips.setText("请选择1场比赛");
		bottom_tv_tips.setText("请选择2场比赛");
		titleBar();

	}

	// 方法由ExpandableListView适配器来调用,转存至全局变量list来显示
	@SuppressWarnings("all")
	public void initMapData(ArrayList<ChildDTO> list_jcdto, String strZQWF) {
		if (strZQWF.equals("RQSPF") || (strZQWF.equals("SPF")) || (strZQWF.equals("YZJS"))) {
			if (ApplicationData.getInstance().getList_jcdto().size() != 0) {
				ApplicationData.getInstance().getList_jcdto().clear();

			}
			for (ChildDTO list_child : list_jcdto) {
				if (!list_child.str_sp.equals("")) {
					ApplicationData.getInstance().getList_jcdto().add(list_child);
				}
			}
		} else if ((strZQWF.equals("SPFRQNEW"))) {
			if (ApplicationData.getInstance().getList_jcdto().size() != 0) {
				ApplicationData.getInstance().getList_jcdto().clear();

			}
			for (ChildDTO list_child : list_jcdto) {
				if (!list_child.str_rqsp.equals("") && list_child.str_rqsp != null) {
					ApplicationData.getInstance().getList_jcdto().add(list_child);
				}
			}

		}else if (strZQWF.equals("BQC")) {
			// 比较APP和传过来的list,如果MID一样，需要删除旧的，添加新的;如果MID不一样，需要直接添加新的
			// 定义一个删除时零时的list
			List<ChildDTO> delList = new ArrayList();
			// // 判断第一次进来全局变量里有没有值.
			if (ApplicationData.getInstance().getList_jcdto().size() != 0) {
				for (ChildDTO app_child : ApplicationData.getInstance().getList_jcdto()) {
					for (ChildDTO list_child : list_jcdto) {
						String app_mid = "";
						String list_mid = "";
						if (app_child.getmId().equals(list_child.getmId())) {
							delList.add(app_child);
						}
					}
				}
				ApplicationData.getInstance().getList_jcdto().removeAll(delList);
			}
			for (ChildDTO list_child : list_jcdto) {
				// 全局变量存贮选择的赛事
				if (!list_child.getBtnBQCcontent().equals("点击弹出下拉列表")) {
					ApplicationData.getInstance().getList_jcdto().add(list_child);
				}
			}

		} else if (strZQWF.equals("ZJQ")) {
			// 比较APP和传过来的list,如果MID一样，需要删除旧的，添加新的;如果MID不一样，需要直接添加新的
			// 定义一个删除时零时的list
			List<ChildDTO> delList = new ArrayList();
			// // 判断第一次进来全局变量里有没有值.
			if (ApplicationData.getInstance().getList_jcdto().size() != 0) {
				for (ChildDTO app_child : ApplicationData.getInstance().getList_jcdto()) {
					for (ChildDTO list_child : list_jcdto) {
						String app_mid = "";
						String list_mid = "";
						if (app_child.getmId().equals(list_child.getmId())) {
							delList.add(app_child);
						}
					}
				}
				ApplicationData.getInstance().getList_jcdto().removeAll(delList);
			}
			for (ChildDTO list_child : list_jcdto) {
				// 全局变量存贮选择的赛事
				if (!list_child.getSelectZJQCG().equals("")) {
					ApplicationData.getInstance().getList_jcdto().add(list_child);
				}
			}
		} else if (strZQWF.equals("BF")) {
			// 比较APP和传过来的list,如果MID一样，需要删除旧的，添加新的;如果MID不一样，需要直接添加新的
			// 定义一个删除时零时的list
			List<ChildDTO> delList = new ArrayList();
			// // 判断第一次进来全局变量里有没有值.
			if (ApplicationData.getInstance().getList_jcdto().size() != 0) {
				for (ChildDTO app_child : ApplicationData.getInstance().getList_jcdto()) {
					for (ChildDTO list_child : list_jcdto) {
						String app_mid = "";
						String list_mid = "";
						if (app_child.getmId().equals(list_child.getmId())) {
							delList.add(app_child);
						}
					}
				}
				ApplicationData.getInstance().getList_jcdto().removeAll(delList);
			}
			for (ChildDTO list_child : list_jcdto) {
				// 全局变量存贮选择的赛事
				if (!((list_child.getBtnbfscontent() + list_child.getBtnbfpcontent() + list_child.getBtnbffcontent())
						.equals("主胜平主负"))) {
					ApplicationData.getInstance().getList_jcdto().add(list_child);
				}
			}
		}

		tv_selectNum.setText(Html.fromHtml("已选 " + "<font color=#fe5052>"
				+ ApplicationData.getInstance().getList_jcdto().size() + "</font>" + " 场"));
		jclist_adapter.notifyDataSetChanged();
	}

	/**
	 * 获取当前期次信息
	 * 
	 * @param strResult
	 * @return
	 */
	private List<Map<String, Object>> getCurrentlData(String strResult) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		try {
			JSONTokener jsonParser = new JSONTokener(strResult);
			JSONObject js = (JSONObject) jsonParser.nextValue();
			list = ConvertJsonToList.getList(js.getString("Data").toString());
		} catch (JSONException e) {
			Log.e("error", e.toString());
		}
		return list;
	}

	/**
	 * 设置按钮显示文字为选择的赛事结果
	 * 
	 */
	public static void btnChildNamechange() {
		jclist_adapter.notifyDataSetChanged();
	}

	// TitleBar标题栏
	public void titleBar() {
		// Title信息(返回+Title)

		TextView back = (TextView) findViewById(R.id.top_title_back);
		back.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				onKeyDown(KeyEvent.KEYCODE_BACK, null);
			}
		});
		top_title_tvplaytype = (TextView) findViewById(R.id.top_title_tvbd);
		top_title_tvplaytype.setText(strLot);
		top_title_tvplaytype.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				LayoutInflater inflater = LayoutInflater.from(JcfootballActivity.this);
				menutypeview = inflater.inflate(R.layout.jczq_menulink, null);
				menu_popupWindow = new PopupWindow(menutypeview, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
				menu_popupWindow.setBackgroundDrawable(new BitmapDrawable());

				menu_popupWindow.setFocusable(true);
				menu_popupWindow.setTouchable(true);
				menu_popupWindow.setOutsideTouchable(false);

				menu_popupWindow.showAtLocation(menutypeview, Gravity.CENTER | Gravity.TOP, 0, 0);
				menu_popupWindow.showAsDropDown(top_title_tvplaytype);
				menutypeview.setOnClickListener(new View.OnClickListener() {
					public void onClick(View v) {
						menu_popupWindow.dismiss();
					}
				});
				setBtnOnClickTopMenu(R.id.jczq_topmenulink_Button1);
				setBtnOnClickTopMenu(R.id.jczq_topmenulink_Button2);
				setBtnOnClickTopMenu(R.id.jczq_topmenulink_Button3);
				setBtnOnClickTopMenu(R.id.jczq_topmenulink_Button4);
				setBtnOnClickTopMenu(R.id.jczq_topmenulink_Button5);
				setBtnOnClickTopMenu(R.id.jczq_topmenulink_Button6);
				setBtnOnClickTopMenu(R.id.jczq_topmenulink_Button7);
				setBtnOnClickTopMenu(R.id.jczq_topmenulink_Button8);
				/*if (strZQWF.equals("YZJS")) {
					((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button1)).setSelected(true);
				} else */if (strZQWF.equals("SPFRQNEW")) {
					((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button2)).setSelected(true);
				} else if (strZQWF.equals("RQSPF")) {
					((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button3)).setSelected(true);
				} else if (strZQWF.equals("SPF")) {
					((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button4)).setSelected(true);
				} else if (strZQWF.equals("ZJQ")) {
					((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button5)).setSelected(true);
				} else if (strZQWF.equals("BF")) {
					((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button6)).setSelected(true);
				} else if (strZQWF.equals("BQC")) {
					((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button7)).setSelected(true);
				} else if (strZQWF.equals("ZQHH")) {
					((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button8)).setSelected(true);
				}

			}

		});

		final TextView refres = (TextView) findViewById(R.id.top_title_refres);
		refres.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				LayoutInflater inflater = LayoutInflater.from(JcfootballActivity.this);
				View menuview = inflater.inflate(R.layout.public_menulink02, null);

				m_popupWindow = new PopupWindow(menuview, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
				m_popupWindow.setBackgroundDrawable(new BitmapDrawable());
				m_popupWindow.setOutsideTouchable(true);
				m_popupWindow.showAtLocation(menuview, Gravity.RIGHT | Gravity.TOP, 0, 0);
				m_popupWindow.showAsDropDown(refres);

				menuview.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						m_popupWindow.dismiss();
					}
				});

				Button public_menulink_Button01 = (Button) menuview.findViewById(R.id.public_menulink_Button01);
				public_menulink_Button01.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						m_popupWindow.dismiss();
						Intent intent;
						if (checkUserLogin()) {
							Intent intent0 = new Intent();
							intent0.putExtra("lotID", LotConstants.LOT_ID_JCZQ);
							intent0.setClass(JcfootballActivity.this, BetRecordActivity.class);
							startActivity(intent0);
						} else {
							intent = new Intent(getApplicationContext(), LoginActivity.class);
							startActivityForResult(intent, REQ_CODE_JCFOOT_LOGIN);
						}
					}
				});
				Button public_menulink_Button02 = (Button) menuview.findViewById(R.id.public_menulink_Button02);
				public_menulink_Button02.setVisibility(View.GONE);
				Button public_menulink_Button03 = (Button) menuview.findViewById(R.id.public_menulink_Button03);
				public_menulink_Button03.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						m_popupWindow.dismiss();
						Intent intent;
						intent = new Intent(getApplicationContext(), KjinfoMatchResult.class);
						intent.putExtra("LotName", getString(R.string.kjinfo_number_f_info));
						startActivity(intent);
					}
				});
				Button public_menulink_Button04 = (Button) menuview.findViewById(R.id.public_menulink_Button04);
				public_menulink_Button04.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						m_popupWindow.dismiss();
						// Intent intent = new
						// Intent(getApplicationContext(),
						// HelpActivity.class);
						// startActivity(intent);

						Intent intent = new Intent(getApplicationContext(), CaiPiaoHelp.class);
						if (strZQWF.equals("YZJS")) {
							intent.putExtra("cp_title", "一场决胜");
							intent.putExtra("cp_url", "1czs.html");
						} else {
							intent.putExtra("cp_title", "竞彩足球");
							intent.putExtra("cp_url", "jczq.html");
						}
						startActivity(intent);
					}
				});
			}
		});
	}

	/**
	 * 菜单玩法按钮事件
	 * 
	 * @param btnId
	 */
	protected void setBtnOnClickTopMenu(final int btnId) {
		Button btn = (Button) menutypeview.findViewById(btnId);
		btn.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				try {
					menu_popupWindow.dismiss();
					setOrderFieldMenu(btnId);
					// 发送不同彩种网络请求
					top_title_tvplaytype.setText(strLot);
					// reset();

				} catch (Exception e) {
					// TODO Auto-generated catch block
					// e.printStackTrace();
				}
			}
		});

	}

	/**
	 * 获取玩法及改变按钮背景
	 * 
	 * @param btnId
	 */
	protected void setOrderFieldMenu(int btnId) {
		// 恢复默认
		((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button1)).setSelected(false);
		((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button2)).setSelected(false);
		((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button3)).setSelected(false);
		((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button4)).setSelected(false);
		((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button5)).setSelected(false);
		((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button6)).setSelected(false);
		((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button7)).setSelected(false);
		((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button8)).setSelected(false);

		switch (btnId) {
		case R.id.jczq_topmenulink_Button1:
			strLot = "一场决胜";
			strZQWF = "YZJS";
			bottom_tv_tips.setText("请选择1场比赛");
			yzjs_tip.setVisibility(View.VISIBLE);
			((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button1)).setSelected(true);
			break;
		case R.id.jczq_topmenulink_Button2:
			strLot = "胜平负/让球";
			strZQWF = "SPFRQNEW";
			bottom_tv_tips.setText("请至少选择2场比赛");
			yzjs_tip.setVisibility(View.GONE);
			((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button2)).setSelected(true);
			break;
		case R.id.jczq_topmenulink_Button3:
			strLot = "让球胜平负";
			strZQWF = "RQSPF";
			bottom_tv_tips.setText("请至少选择2场比赛");
			yzjs_tip.setVisibility(View.GONE);
			((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button3)).setSelected(true);
			break;
		case R.id.jczq_topmenulink_Button4:
			strLot = "胜平负";
			strZQWF = "SPF";
			bottom_tv_tips.setText("请至少选择2场比赛");
			yzjs_tip.setVisibility(View.GONE);
			((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button4)).setSelected(true);
			break;
		case R.id.jczq_topmenulink_Button5:
			strLot = "总进球";
			strZQWF = "ZJQ";
			bottom_tv_tips.setText("请至少选择1场比赛");
			yzjs_tip.setVisibility(View.GONE);
			((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button5)).setSelected(true);
			break;
		case R.id.jczq_topmenulink_Button6:
			strLot = "比分";
			strZQWF = "BF";
			bottom_tv_tips.setText("请至少选择1场比赛");
			yzjs_tip.setVisibility(View.GONE);
			((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button6)).setSelected(true);
			break;
		case R.id.jczq_topmenulink_Button7:
			strLot = "半全场";
			strZQWF = "BQC";
			bottom_tv_tips.setText("请至少选择1场比赛");
			yzjs_tip.setVisibility(View.GONE);
			((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button7)).setSelected(true);
			break;
		case R.id.jczq_topmenulink_Button8:
			strLot = "混合过关";
			strZQWF = "ZQHH";
			bottom_tv_tips.setText("请至少选择2场比赛");
			yzjs_tip.setVisibility(View.GONE);
			((Button) menutypeview.findViewById(R.id.jczq_topmenulink_Button8)).setSelected(true);
			break;
		}
		clearData();
		// 获取比赛场次信息赋值给groups
		getMatchInfo();
		// changeMatchInfo();
		// 构建ExpandableListView的适配器
		if (TextUtils.equals(strZQWF, "ZQHH") || TextUtils.equals(strZQWF, "SPFRQNEW")) {
			jczq_hhtz_adapter = new FootBallHHTZAdapter(JcfootballActivity.this, groups);
			jclist.setAdapter(jczq_hhtz_adapter);
		} else {
			jclist_adapter = new BaseGroupAdapter(JcfootballActivity.this, groups, strZQWF);
			jclist.setAdapter(jclist_adapter); // 绑定视图－适配器
		}

		jclist.expandGroup(0);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		if (m_popupWindow != null) {
			m_popupWindow.dismiss();
		}
		return super.onTouchEvent(event);
	}

	public boolean checkUserLogin() {
		return true == ApplicationData.getInstance().isUserLogin();
	}

	/**
	 * 清除用户选择的数据，恢复初始状态
	 */
	public void clearData() {
		// 清除数据
		if (groups != null) {
			for (int i = 0; i < groups.size(); i++) {
				if (groups.get(i).children.size() > 0) {
					// 若children不为空，循环设置children的checked
					for (ChildDTO child : groups.get(i).children) {
						if (strZQWF.equals("RQSPF") || (strZQWF.equals("SPF")) || (strZQWF.equals("YZJS"))
								|| (strZQWF.equals("SPFRQNEW"))) {
							child.str_sbtn = false;
							child.str_fbtn = false;
							child.str_pbtn = false;
							child.str_rqsbtn = false;
							child.str_rqfbtn = false;
							child.str_rqpbtn = false;
							child.str_sp = "";
						} else if (strZQWF.equals("BQC")) {
							// 半全场赛果gridview是否显示
							child.setShowBQCGrid(false);
							child.str_sbtn = false;
							// 半全场赛果gridview按钮状态初始化
							List<String> list_gridview_selectstate = new ArrayList<String>();
							for (int k = 0; k < 9; k++) {// 半全场9中赛果
								list_gridview_selectstate.add("false");
							}
							child.setList_bqcgridview_selectstate(list_gridview_selectstate);
							child.setBtnBQCcontent("点击弹出下拉列表");
							List<String> list_gridview_selectcon = new ArrayList<String>();
							child.setList_bqcgridview_selectconcent(list_gridview_selectcon);
							// 半全场赛果gridview按钮SP list初始化
							List<String> list_gridview_selectsp = new ArrayList<String>();
							for (int k = 0; k < 9; k++) {// 半全场9中赛果sp
								list_gridview_selectsp.add("0");
							}
							child.setList_bqcgridview_selectsp(list_gridview_selectsp);
							child.setBqc_selectsp("");
						} else if (strZQWF.equals("ZJQ")) {
							// 总进球gridview按钮状态初始化
							List<String> list_gridview_selectstate = new ArrayList<String>();
							for (int k = 0; k < 8; k++) {// 总进球8种赛果
								list_gridview_selectstate.add("false");
							}
							child.setList_zjqgridview_selectstate(list_gridview_selectstate);
							child.setSelectZJQCG("");
							List<String> list_gridview_selectcon = new ArrayList<String>();
							child.setList_zjqgridview_selectconcent(list_gridview_selectcon);
							// 总进球gridview按钮sp list初始化
							List<String> list_gridview_selectsp = new ArrayList<String>();
							for (int k = 0; k < 8; k++) {// 总进球8种赛果sp
								list_gridview_selectsp.add("0");
							}
							child.setList_zjqgridview_selectsp(list_gridview_selectsp);
							child.setBqc_selectsp("");
						} else if (strZQWF.equals("BF")) {
							// 比分主胜gridview是否显示
							child.setShowBFS(false);
							child.setShowBFP(false);
							child.setShowBFF(false);
							// 设置按钮选择状态为未选择
							child.setStr_sbtn(false);
							child.setStr_fbtn(false);
							child.setStr_pbtn(false);
							// 比分主胜gridview按钮状态初始化
							List<String> list_bfsgridview_selectstate = new ArrayList<String>();
							for (int k = 0; k < 13; k++) {// 比分主胜13种赛果
								list_bfsgridview_selectstate.add("false");
							}
							child.setList_bfsgridview_selectstate(list_bfsgridview_selectstate);
							// 比分平gridview按钮状态初始化
							List<String> list_bfpgridview_selectstate = new ArrayList<String>();
							for (int k = 0; k < 5; k++) {// 比分平5种赛果
								list_bfpgridview_selectstate.add("false");
							}
							child.setList_bfpgridview_selectstate(list_bfpgridview_selectstate);
							// 比分主负gridview按钮状态初始化
							List<String> list_bffgridview_selectstate = new ArrayList<String>();
							for (int k = 0; k < 13; k++) {// 比分主负13种赛果
								list_bffgridview_selectstate.add("false");
							}
							child.setList_bffgridview_selectstate(list_bffgridview_selectstate);
							// 设置按钮初始文字内容
							child.setBtnbfscontent("主胜");
							child.setBtnbfpcontent("平");
							child.setBtnbffcontent("主负");
							// 比分主胜gridview按钮选择内容初始化
							List<String> list_bfsgridview_selectconcent = new ArrayList<String>();
							child.setList_bfsgridview_selectconcent(list_bfsgridview_selectconcent);
							// 比分平gridview按钮选择内容初始化
							List<String> list_bfpgridview_selectconcent = new ArrayList<String>();
							child.setList_bfpgridview_selectconcent(list_bfpgridview_selectconcent);
							// 比分主负gridview按钮选择内容初始化
							List<String> list_bffgridview_selectconcent = new ArrayList<String>();
							child.setList_bffgridview_selectconcent(list_bffgridview_selectconcent);
							child.setBtnbfAllcontent("");
							// 比分sp值选择list初始化
							List<String> list_bfsgridview_selectsp = new ArrayList<String>();
							for (int k = 0; k < 13; k++) {// 比分主胜13种赛果SP
								list_bfsgridview_selectsp.add("0");
							}
							child.setList_bfsgridview_selectsp(list_bfsgridview_selectsp);

							List<String> list_bfpgridview_selectsp = new ArrayList<String>();
							for (int k = 0; k < 5; k++) {// 比分平5种赛果SP
								list_bfpgridview_selectsp.add("0");
							}
							child.setList_bfpgridview_selectsp(list_bfpgridview_selectsp);

							List<String> list_bffgridview_selectsp = new ArrayList<String>();
							for (int k = 0; k < 13; k++) {// 比分主负13种赛果SP
								list_bffgridview_selectsp.add("0");
							}
							child.setList_bffgridview_selectsp(list_bffgridview_selectsp);
							child.setBqc_selectsp("");
						}
					}
					ArrayList<ChildDTO> list_jcdto = new ArrayList<ChildDTO>();
					ApplicationData.getInstance().setList_jcdto(list_jcdto);
					if (TextUtils.equals(strZQWF, "ZQHH") || TextUtils.equals(strZQWF, "SPFRQNEW")) {
						if (jczq_hhtz_adapter != null)
							jczq_hhtz_adapter.notifyDataSetChanged();
					} else {
						jclist_adapter.notifyDataSetChanged();
					}

					tv_selectNum.setText(Html.fromHtml("已选 " + "<font color=#fe5052>" + 0 + "</font>" + " 场"));

				}
			}
		}
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			// 跳转至-开奖信息主页面
			if(ifPush){
				Intent intent = new Intent(this, JddMainActivity.class);
				startActivity(intent);
			}
			this.finish();
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}
	};

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == REQ_CODE_BUYMAIN && resultCode == RESULT_OK) {
			onKeyDown(KeyEvent.KEYCODE_BACK, null);
		}
		// 从投注记录回退时，需要清除数据
		if (resultCode == 0) {
			// clearData();
		}
		if (resultCode == RESULT_CANCELED) {
			if (requestCode == REQ_CODE_JCFOOT) {
				clearData();
			}
		}
		if (resultCode == RESULT_OK) {
			if (requestCode == REQ_CODE_LQHHTZ) {
				jczq_hhtz_adapter.refreshWithData(data.getIntExtra("gindex", 0), data.getIntExtra("cindex", 0),
						(ChildDTO) data.getSerializableExtra("info"));
				;
			}
			if (requestCode == REQ_CODE_JCFOOT_LOGIN) {
				jczqSubmit();
			} else if (requestCode == REQ_CODE_JCFOOT) {
				onKeyDown(KeyEvent.KEYCODE_BACK, null);
			} else {
				clearData();
			}
		}
		if (resultCode == 110) {
			onKeyDown(KeyEvent.KEYCODE_BACK, null);
		}
	};

	@Override
	public void finish() {
		// TODO Auto-generated method stub
		super.finish();
		try {
		} catch (Exception e) {
			// TODO Auto-generated catch block
			// e.printStackTrace();
		}
	};

	class FootBallHHTZAdapter extends BaseExpandableListAdapter implements Serializable {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		private Context context; // 父activity
		LayoutInflater inflater;
		private ArrayList<GroupDTO> datas;
		private Map<String, Integer> sel = new HashMap<String, Integer>();

		public FootBallHHTZAdapter(Context c, List<GroupDTO> datas) {
			context = c;
			sel.clear();
			inflater = (LayoutInflater) c.getSystemService(LAYOUT_INFLATER_SERVICE);
			this.datas = (ArrayList<GroupDTO>) datas;
		}

		public int getSelNum() {
			return (sel.isEmpty() ? 0 : sel.size());
		}

		public void clearSel() {
			for (GroupDTO gto : datas) {
				for (ChildDTO cto : gto.children) {
					cto.hhtzzq1 = "";
					cto.hhtzzq2 = "";
					cto.hhtzzq3 = "";
					cto.hhtzzq4 = "";
					cto.hhtzzq5 = "";
					cto.zqhhtzsp = "";
				}
			}
			sel.clear();
			this.notifyDataSetChanged();
		}

		public void refreshWithData(int gid, int cid, ChildDTO cDto) {
			datas.get(gid).children.remove(cid);
			datas.get(gid).children.add(cid, cDto);
			this.notifyDataSetChanged();
		}

		public ArrayList<GroupDTO> getDatas() {
			return datas;
		}

		@Override
		public Object getChild(int groupPosition, int childPosition) {
			// TODO Auto-generated method stub
			return datas.get(groupPosition).children.get(childPosition);
		}

		@Override
		public long getChildId(int groupPosition, int childPosition) {
			// TODO Auto-generated method stub
			return childPosition;
		}

		@Override
		public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild,
				View convertView, ViewGroup parent) {

			if (TextUtils.equals(strZQWF, "ZQHH")) {

				// TODO Auto-generated method stub
				ChildExpandableListHolder holder = null; // 清空临时变量
				if (convertView == null) { // 若行未初始化
					// 通过flater初始化行视图
					convertView = inflater.inflate(R.layout.ui_new_jczq_hhgg_item, null);
					// 并将行视图的5个子视图引用放到tag中
					holder = new ChildExpandableListHolder();
					holder.tv_item_no_endtime = (TextView) convertView.findViewById(R.id.tv_item_no_endtime);
					holder.textView_matchname = (TextView) convertView.findViewById(R.id.tv_item_match_name);
					holder.tv_hTeam = (TextView) convertView.findViewById(R.id.tv_item_hteam);
					holder.tv_vTeam = (TextView) convertView.findViewById(R.id.tv_item_vteam);
					holder.btn_zf = (Button) convertView.findViewById(R.id.btn_item_s);
					holder.tv_item_match_issingle = (TextView) convertView.findViewById(R.id.tv_item_match_issingle);
					convertView.setTag(holder);
				} else { // 若行已初始化，直接从tag属性获得子视图的引用
					holder = (ChildExpandableListHolder) convertView.getTag();
				}

				final GroupDTO info1 = this.datas.get(groupPosition);
				// 获得行数据（模型）
				final String wkn = DateUtil.getTName(info1.title);
				final ChildDTO info = this.datas.get(groupPosition).children.get(childPosition);
				if (info != null) {
					holder.tv_item_match_issingle.setVisibility(info.isSingle()==1 ? View.VISIBLE:View.INVISIBLE);
					String str_nmu = "";
					// 根据模型数据，设置行视图的控件值
					if (info.nMm.length() < 4) {
						str_nmu = info.nMm;
					} else {
						str_nmu = info.nMm.substring(0, 4);
					}

					holder.tv_item_no_endtime
							.setText((info.mId).substring(6) + " " + DateUtil.getDateTime1(info.eTime));// 130718301
					holder.tv_hTeam.setText(info.hTeam);
					holder.tv_vTeam.setText(info.vTeam);
					holder.textView_matchname.setText(str_nmu);
					String btnName = "";
					if (!TextUtils.isEmpty(info.hhtzzq1)) {
						if (info.hhtzzq1.length() >= 1) {
							btnName += " 胜平负:";
							if (info.hhtzzq1.contains("3")) {
								btnName += " 胜";
							}
							if (info.hhtzzq1.contains("1")) {
								btnName += " 平";
							}
							if (info.hhtzzq1.contains("0")) {
								btnName += " 负";
							}
						}
					}
					if (!TextUtils.isEmpty(info.hhtzzq2)) {
						if (info.hhtzzq2.length() >= 1) {
							btnName += " 让球胜平负:";
							if (info.hhtzzq2.contains("3")) {
								btnName += " 胜";
							}
							if (info.hhtzzq2.contains("1")) {
								btnName += " 平";
							}
							if (info.hhtzzq2.contains("0")) {
								btnName += " 负";
							}
						}
					}
					if (!TextUtils.isEmpty(info.hhtzzq3)) {
						if (info.hhtzzq3.length() >= 1) {
							btnName += " 半全场:";
							if (info.hhtzzq3.contains("a")) {
								btnName += " 胜胜";
							}
							if (info.hhtzzq3.contains("b")) {
								btnName += " 胜平";
							}
							if (info.hhtzzq3.contains("c")) {
								btnName += " 胜负";
							}
							if (info.hhtzzq3.contains("d")) {
								btnName += " 平胜";
							}
							if (info.hhtzzq3.contains("e")) {
								btnName += " 平平";
							}
							if (info.hhtzzq3.contains("f")) {
								btnName += " 平负";
							}
							if (info.hhtzzq3.contains("g")) {
								btnName += " 负胜";
							}
							if (info.hhtzzq3.contains("h")) {
								btnName += " 负平";
							}
							if (info.hhtzzq3.contains("i")) {
								btnName += " 负负";
							}
						}
					}
					if (!TextUtils.isEmpty(info.hhtzzq4)) {
						if (info.hhtzzq4.length() >= 1) {
							btnName += " 总进球:";
							if (info.hhtzzq4.contains("0")) {
								btnName += " 0";
							}
							if (info.hhtzzq4.contains("1")) {
								btnName += " 1";
							}
							if (info.hhtzzq4.contains("2")) {
								btnName += " 2";
							}
							if (info.hhtzzq4.contains("3")) {
								btnName += " 3";
							}
							if (info.hhtzzq4.contains("4")) {
								btnName += " 4";
							}
							if (info.hhtzzq4.contains("5")) {
								btnName += " 5";
							}
							if (info.hhtzzq4.contains("6")) {
								btnName += " 6";
							}
							if (info.hhtzzq4.contains("7")) {
								btnName += " 7+";
							}
						}
					}
					if (!TextUtils.isEmpty(info.hhtzzq5)) {
						if (info.hhtzzq5.length() >= 1) {
							btnName += " 比分:";
							if (info.hhtzzq5.contains("a")) {
								btnName += " 1:0";
							}
							if (info.hhtzzq5.contains("b")) {
								btnName += " 2:0";
							}
							if (info.hhtzzq5.contains("c")) {
								btnName += " 2:1";
							}
							if (info.hhtzzq5.contains("d")) {
								btnName += " 3:0";
							}
							if (info.hhtzzq5.contains("e")) {
								btnName += " 3:1";
							}
							if (info.hhtzzq5.contains("f")) {
								btnName += " 3:2";
							}
							if (info.hhtzzq5.contains("g")) {
								btnName += " 4:0";
							}
							if (info.hhtzzq5.contains("h")) {
								btnName += " 4:1";
							}
							if (info.hhtzzq5.contains("i")) {
								btnName += " 4:2";
							}
							if (info.hhtzzq5.contains("j")) {
								btnName += " 5:0";
							}
							if (info.hhtzzq5.contains("k")) {
								btnName += " 5:1";
							}
							if (info.hhtzzq5.contains("l")) {
								btnName += " 5:2";
							}
							if (info.hhtzzq5.contains("m")) {
								btnName += " 胜其他";
							}
							if (info.hhtzzq5.contains("n")) {
								btnName += " 0:0";
							}
							if (info.hhtzzq5.contains("o")) {
								btnName += " 1:1";
							}
							if (info.hhtzzq5.contains("p")) {
								btnName += " 2:2";
							}
							if (info.hhtzzq5.contains("q")) {
								btnName += " 3:3";
							}
							if (info.hhtzzq5.contains("r")) {
								btnName += " 平其他";
							}
							if (info.hhtzzq5.contains("s")) {
								btnName += " 0:1";
							}
							if (info.hhtzzq5.contains("t")) {
								btnName += " 0:2";
							}
							if (info.hhtzzq5.contains("u")) {
								btnName += " 1:2";
							}
							if (info.hhtzzq5.contains("v")) {
								btnName += " 0:3";
							}
							if (info.hhtzzq5.contains("w")) {
								btnName += " 1:3";
							}
							if (info.hhtzzq5.contains("x")) {
								btnName += " 2:3";
							}
							if (info.hhtzzq5.contains("y")) {
								btnName += " 0:4";
							}
							if (info.hhtzzq5.contains("z")) {
								btnName += " 1:4";
							}
							if (info.hhtzzq5.contains("1")) {
								btnName += " 2:4";
							}
							if (info.hhtzzq5.contains("2")) {
								btnName += " 0:5";
							}
							if (info.hhtzzq5.contains("3")) {
								btnName += " 1:5";
							}
							if (info.hhtzzq5.contains("4")) {
								btnName += " 2:5";
							}
							if (info.hhtzzq5.contains("5")) {
								btnName += " 负其他";
							}
						}
					}
					String key = groupPosition + "" + childPosition;
					if (btnName.length() >= 2) {
						holder.btn_zf.setText(btnName.length() > 16 ? btnName.substring(0, 16) + "..." : btnName);
						holder.btn_zf.setSelected(true);
						if (sel.containsKey(key) == false) {
							sel.put(key, 1);
						}
					} else {
						holder.btn_zf.setText("选择赛事方案");
						holder.btn_zf.setSelected(false);
						if (sel.containsKey(key) == true) {
							sel.remove(key);
						}
					}
					tv_selectNum.setText(Html.fromHtml("已选 " + "<font color=#fe5052>" + jczq_hhtz_adapter.getSelNum()
							+ "</font>" + " 场"));

					holder.btn_zf.setTag(info);
					holder.btn_zf.setOnClickListener(new OnClickListener() {

						@Override
						public void onClick(View arg0) {
							// TODO Auto-generated method stub
							Intent intent = new Intent(JcfootballActivity.this, JczqHhtz.class);
							intent.putExtra("info", info);
							intent.putExtra("wk", wkn);
							intent.putExtra("gindex", groupPosition);
							intent.putExtra("cindex", childPosition);
							startActivityForResult(intent, REQ_CODE_LQHHTZ);
						}
					});
				}

			} else if (TextUtils.equals(strZQWF, "SPFRQNEW")) {

				ChildExpandableListHolderRQSPF holderRQSPF = null; // 让球胜平负和胜平负清空临时变量
				// 通过flater初始化行视图
				convertView = inflater.inflate(R.layout.jczq_spf_rq_item, null);
				// 并将行视图的5个子视图引用放到tag中
				holderRQSPF = new ChildExpandableListHolderRQSPF();
				holderRQSPF.tv_item_no_endtime = (TextView) convertView.findViewById(R.id.tv_item_no_endtime);
				holderRQSPF.tv_matchname = (TextView) convertView.findViewById(R.id.tv_item_match_name);
				holderRQSPF.tv_hteam = (TextView) convertView.findViewById(R.id.tv_item_hteam);
				holderRQSPF.tv_vteam = (TextView) convertView.findViewById(R.id.tv_item_vteam);
				holderRQSPF.tv_item_vs_or_rq = (TextView) convertView.findViewById(R.id.tv_item_vs_or_rq);
				holderRQSPF.btn_s = (Button) convertView.findViewById(R.id.btn_item_s);
				holderRQSPF.btn_p = (Button) convertView.findViewById(R.id.btn_item_p);
				holderRQSPF.btn_f = (Button) convertView.findViewById(R.id.btn_item_f);

				holderRQSPF.tv_hteam_name_01 = (TextView) convertView.findViewById(R.id.txt_jczq_spf_rq_01);
				holderRQSPF.tv_hteam_name_02 = (TextView) convertView.findViewById(R.id.txt_jczq_spf_rq_02);

				holderRQSPF.btn_s_02 = (Button) convertView.findViewById(R.id.btn_item_s_02);
				holderRQSPF.btn_p_02 = (Button) convertView.findViewById(R.id.btn_item_p_02);
				holderRQSPF.btn_f_02 = (Button) convertView.findViewById(R.id.btn_item_f_02);

				final ChildDTO info = this.datas.get(groupPosition).children.get(childPosition);
				if (info != null) {
					String str_eq = "";
					String str_nmu = "";
					// 根据模型数据，设置行视图的控件值
					if (!info.eQ.equals("0")) {
						str_eq = info.eQ;
					} else {
						str_eq = "-";
					}
					if (info.nMm.length() < 4) {
						str_nmu = info.nMm;
					} else {
						str_nmu = info.nMm.substring(0, 4);
					}

					// holderRQSPF.textView_wk.setText(DateUtil.getGameNo(info.mId));
					// 格式修改 130909001 截取后3位001
					holderRQSPF.tv_item_no_endtime.setText(info.mId.substring(info.mId.length() - 3, info.mId.length())
							+ " " + DateUtil.getDateTime1(info.eTime));
					holderRQSPF.tv_matchname.setText(str_nmu);
					holderRQSPF.tv_hteam.setText(info.hTeam);
					holderRQSPF.tv_vteam.setText(info.vTeam);
					holderRQSPF.tv_hteam_name_01.setText(0 + "");
					int int_eq = Integer.parseInt(str_eq);
					if (int_eq >= 1) {
						holderRQSPF.tv_hteam_name_02.setBackgroundResource(R.drawable.ui_new_btn_red);
						holderRQSPF.tv_hteam_name_02.setText(str_eq);
					} else {
						holderRQSPF.tv_hteam_name_02.setBackgroundResource(R.drawable.ui_new_btn_blue);
						holderRQSPF.tv_hteam_name_02.setText(str_eq);
					}
					if (!info.getsPspf().equals("") && !info.getsPRqspf().equals("")) {
						holderRQSPF.btn_s.setText("胜" + info.getsPspf().split("\\|")[0]);
						holderRQSPF.btn_p.setText("平" + info.getsPspf().split("\\|")[1]);
						holderRQSPF.btn_f.setText("胜" + info.getsPspf().split("\\|")[2]);
						holderRQSPF.btn_s_02.setText("胜" + info.getsPRqspf().split("\\|")[0]);
						holderRQSPF.btn_p_02.setText("平" + info.getsPRqspf().split("\\|")[1]);
						holderRQSPF.btn_f_02.setText("胜" + info.getsPRqspf().split("\\|")[2]);

						// holderRQSPF.btn_s.setTag(info.getsPspf().split("\\|")[0]);
						// holderRQSPF.btn_p.setTag(info.getsPspf().split("\\|")[1]);
						// holderRQSPF.btn_f.setTag(info.getsPspf().split("\\|")[2]);
						// holderRQSPF.btn_s_02.setTag(info.getsPRqspf().split("\\|")[0]);
						// holderRQSPF.btn_p_02.setTag(info.getsPRqspf().split("\\|")[1]);
						// holderRQSPF.btn_f_02.setTag(info.getsPRqspf().split("\\|")[2]);
					} else {
						holderRQSPF.btn_s.setText("胜" + "-");
						holderRQSPF.btn_p.setText("平" + "-");
						holderRQSPF.btn_f.setText("胜" + "-");
						holderRQSPF.btn_s_02.setText("胜" + "-");
						holderRQSPF.btn_p_02.setText("平" + "-");
						holderRQSPF.btn_f_02.setText("胜" + "-");
					}

					holderRQSPF.btn_s.setSelected(info.str_sbtn);
					holderRQSPF.btn_p.setSelected(info.str_pbtn);
					holderRQSPF.btn_f.setSelected(info.str_fbtn);
					holderRQSPF.btn_s_02.setSelected(info.str_rqsbtn);
					holderRQSPF.btn_p_02.setSelected(info.str_rqpbtn);
					holderRQSPF.btn_f_02.setSelected(info.str_rqfbtn);

					// holderRQSPF.btn_s.setTag(info);
					// holderRQSPF.btn_p.setTag(info);
					// holderRQSPF.btn_f.setTag(info);
					// holderRQSPF.btn_s_02.setTag(info);
					// holderRQSPF.btn_p_02.setTag(info);
					// holderRQSPF.btn_f_02.setTag(info);

					final String key = groupPosition + "" + childPosition;

					// spf s btn
					holderRQSPF.btn_s.setOnClickListener(new View.OnClickListener() {
						@Override
						public void onClick(View v) {
							if (info.str_sbtn) {
								info.str_sbtn = false;
								info.hhtzzq1 = info.hhtzzq1.replace("3", "");
							} else {
								info.str_sbtn = true;
								info.hhtzzq1 += "3";
							}

							if (info.str_sbtn) {
								if (sel.containsKey(key) == false) {
									sel.put(key, 1);
								}
							} else {
								if (sel.containsKey(key) == true) {
									if (!info.str_sbtn && !info.str_pbtn && !info.str_fbtn && !info.str_rqsbtn
											&& !info.str_rqpbtn && !info.str_rqfbtn) {
										sel.remove(key);
									}
								}
							}

							jczq_hhtz_adapter.refreshWithData(groupPosition, childPosition, info);
						}
					});

					// rq s btn
					holderRQSPF.btn_s_02.setOnClickListener(new View.OnClickListener() {
						@Override
						public void onClick(View v) {
							if (info.str_rqsbtn) {
								info.str_rqsbtn = false;
								info.hhtzzq2 = info.hhtzzq2.replace("3", "");
							} else {
								info.str_rqsbtn = true;
								info.hhtzzq2 += "3";
							}

							if (info.str_rqsbtn) {
								if (sel.containsKey(key) == false) {
									sel.put(key, 1);
								}
							} else {
								if (sel.containsKey(key) == true) {
									if (!info.str_sbtn && !info.str_pbtn && !info.str_fbtn && !info.str_rqsbtn
											&& !info.str_rqpbtn && !info.str_rqfbtn) {
										sel.remove(key);
									}
								}
							}

							jczq_hhtz_adapter.refreshWithData(groupPosition, childPosition, info);
						}
					});

					// spf p btn
					holderRQSPF.btn_p.setOnClickListener(new View.OnClickListener() {
						@Override
						public void onClick(View v) {
							if (info.str_pbtn) {
								info.str_pbtn = false;
								info.hhtzzq1 = info.hhtzzq1.replace("1", "");
							} else {
								info.str_pbtn = true;
								info.hhtzzq1 += "1";
							}

							if (info.str_pbtn) {
								if (sel.containsKey(key) == false) {
									sel.put(key, 1);
								}
							} else {
								if (sel.containsKey(key) == true) {
									if (!info.str_sbtn && !info.str_pbtn && !info.str_fbtn && !info.str_rqsbtn
											&& !info.str_rqpbtn && !info.str_rqfbtn) {
										sel.remove(key);
									}
								}
							}

							jczq_hhtz_adapter.refreshWithData(groupPosition, childPosition, info);
						}
					});

					// rqspf p btn
					holderRQSPF.btn_p_02.setOnClickListener(new View.OnClickListener() {
						@Override
						public void onClick(View v) {
							if (info.str_rqpbtn) {
								info.str_rqpbtn = false;
								info.hhtzzq2 = info.hhtzzq2.replace("1", "");
							} else {
								info.str_rqpbtn = true;
								info.hhtzzq2 += "1";
							}

							if (info.str_rqpbtn) {
								if (sel.containsKey(key) == false) {
									sel.put(key, 1);
								}
							} else {
								if (sel.containsKey(key) == true) {
									if (!info.str_sbtn && !info.str_pbtn && !info.str_fbtn && !info.str_rqsbtn
											&& !info.str_rqpbtn && !info.str_rqfbtn) {
										sel.remove(key);
									}
								}
							}

							jczq_hhtz_adapter.refreshWithData(groupPosition, childPosition, info);
						}
					});

					// spf f btn
					holderRQSPF.btn_f.setOnClickListener(new View.OnClickListener() {
						@Override
						public void onClick(View v) {
							if (info.str_fbtn) {
								info.str_fbtn = false;
								info.hhtzzq1 = info.hhtzzq1.replace("0", "");
							} else {
								info.str_fbtn = true;
								info.hhtzzq1 += "0";
							}

							if (info.str_fbtn) {
								if (sel.containsKey(key) == false) {
									sel.put(key, 1);
								}
							} else {
								if (sel.containsKey(key) == true) {
									if (!info.str_sbtn && !info.str_pbtn && !info.str_fbtn && !info.str_rqsbtn
											&& !info.str_rqpbtn && !info.str_rqfbtn) {
										sel.remove(key);
									}
								}
							}

							jczq_hhtz_adapter.refreshWithData(groupPosition, childPosition, info);
						}
					});

					// rqspf f btn
					holderRQSPF.btn_f_02.setOnClickListener(new View.OnClickListener() {
						@Override
						public void onClick(View v) {
							if (info.str_rqfbtn) {
								info.str_rqfbtn = false;
								info.hhtzzq2 = info.hhtzzq2.replace("0", "");
							} else {
								info.str_rqfbtn = true;
								info.hhtzzq2 += "0";
							}

							if (info.str_rqfbtn) {
								if (sel.containsKey(key) == false) {
									sel.put(key, 1);
								}
							} else {
								if (sel.containsKey(key) == true) {
									if (!info.str_sbtn && !info.str_pbtn && !info.str_fbtn && !info.str_rqsbtn
											&& !info.str_rqpbtn && !info.str_rqfbtn) {
										sel.remove(key);
									}
								}
							}

							jczq_hhtz_adapter.refreshWithData(groupPosition, childPosition, info);
						}
					});
				}

				tv_selectNum.setText(Html.fromHtml("已选 " + "<font color=#fe5052>" + jczq_hhtz_adapter.getSelNum()
						+ "</font>" + " 场"));

			}

			return convertView;

		}

		@Override
		public int getChildrenCount(int groupPosition) {
			// TODO Auto-generated method stub
			if (datas.size() <= 0) {
				return 0;
			}
			return datas.get(groupPosition).children.size();
		}

		@Override
		public Object getGroup(int groupPosition) {
			// TODO Auto-generated method stub
			return datas.get(groupPosition);
		}

		@Override
		public int getGroupCount() {
			// TODO Auto-generated method stub
			return datas.size();
		}

		@Override
		public long getGroupId(int groupPosition) {
			// TODO Auto-generated method stub
			return groupPosition;
		}

		@Override
		public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			GroupExpandableListHolder holder = null;
			if (convertView == null) {
				convertView = inflater.inflate(R.layout.item_group, null);
				holder = new GroupExpandableListHolder();
				holder.title = (TextView) convertView.findViewById(R.id.item_group_title);
				holder.indicator = (ImageView) convertView.findViewById(R.id.item_group_status);
				convertView.setTag(holder);
			} else {
				holder = (GroupExpandableListHolder) convertView.getTag();
			}
			// 未完成
			GroupDTO info = this.datas.get(groupPosition);
			if (info != null) {
				// 根据模型值设置textview的文本
				holder.title.setText(DateUtil.getTName(info.title));
			}
			if (true == isExpanded) {
				holder.indicator.setImageResource(R.drawable.hemai_up);
			} else {
				holder.indicator.setImageResource(R.drawable.hemai_down);
			}
			return convertView;
		}

		@Override
		public boolean hasStableIds() {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean isChildSelectable(int groupPosition, int childPosition) {
			// TODO Auto-generated method stub
			return false;
		}

		// 定义一个内部类，用于保存父View
		private class GroupExpandableListHolder {
			TextView title;
			ImageView indicator;
		}

		// 定义一个内部类，用于保存子View
		private class ChildExpandableListHolder {
			TextView tv_item_no_endtime, textView_matchname, tv_vTeam, tv_hTeam,tv_item_match_issingle;
			Button btn_zf;// 胜
		}

		private class ChildExpandableListHolderRQSPF {
			TextView tv_item_no_endtime, tv_matchname, tv_week;
			TextView tv_hteam, tv_vteam, tv_item_vs_or_rq;
			Button btn_s, btn_s_02;
			Button btn_p, btn_p_02;
			Button btn_f, btn_f_02;
			TextView tv_hteam_name_01, tv_hteam_name_02;
			View linearLayout01;
		}

	}

}
